﻿/**
 * ...
 * @author 
 */

package list;
import gui.hug.HUGSprite;
import gui.hug.HUGLabel;
import gui.hug.Utils;
import gui.hug.HUGColors;
import flash.events.MouseEvent;
import loader.Loader;
import client.Item;

class FriendPanel extends HUGSprite
{
	public var friendName : String;
	public var friendID : Int;
	private var itemID : Int;
	public var sendButton : MyLinkButton;
	public var nameLabel : HUGLabel;
	
	static private inline var BACKGROUND_COLOR : UInt = HUGColors.VK_BORDER_INNER;
	static private inline var BORDER_COLOR : UInt = HUGColors.WHITE;

	public function new(name : String, id : Int, item : Int) 
	{
		super();
		friendName = name;
		friendID = id;
		itemID = item;
		nameLabel = new HUGLabel();
		nameLabel.text = name;
		nameLabel.width = 100;
		nameLabel.height = 20;
		nameLabel.x = 0;
		nameLabel.y = 0;
		nameLabel.visible = true;
		sendButton = new MyLinkButton();
		sendButton.setNewText("Отправить");
		sendButton.setLocation(20, 20);
		sendButton.visible = true;
		sendButton.addEventListener(MouseEvent.CLICK, onClick);
		Utils.rect(this, 0, 0, 200, 50, BACKGROUND_COLOR, BORDER_COLOR);
		this.addChild(sendButton);
		this.addChild(nameLabel);
		
	}
	
	private function onClick (e : MouseEvent) {
		var l : Loader = Loader.getInstance();
		var stub = function (t : Array<Item>) {
			
		}
		l.sendMessage(stub, friendID, itemID);
		this.parent.parent.visible = false;
	}
	
	public function getHeight() : Float {
		return 50;
	}
}